package com.lhd.action.memento;

/**
 * @Author: liuhd
 * @Date: 2024/12/19 16:58
 * @Description:
 */
public class UserInfo {
    private String username;
    private String password;

    public UserInfo(String username, String password) {
        this.username = username;
        this.password = password;
    }
    // 保存状态
    public Memento saveState(){
        return new Memento(username,password);
    }
    // 恢复状态
    public void restoreState(Memento memento){
        this.username = memento.getUsername();
        this.password = memento.getPassword();
    }
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "UserInfo{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
